class Solution {
public:
    int peakIndexInMountainArray(vector<int>& a) {
        int l = 0, r = a.size();
        while (l + 1 < r) {
            int mid = l + r >> 1;
            if (a[mid] >= a[mid - 1])l = mid;
            else r = mid;
        }
        return l;
    }
};